Data structure for texture data, computer program product, and texture mapping method

ABSTRACT

The present invention has as an object to propose a texture mapping method which enables smooth shading, and is also appropriate for conserving memory resources. In order to achieve this object, in this invention, data regions with different color tones are set so as to form density gradients in the U coordinate direction and in the V coordinate direction of the texture data. If the brightness of the surface of the object to which texture mapping is performed is I, then among the coordinates to be read to access texture fdata, the U coordinate is calculated as U=a*I+b, and the V coordinate is determined from V=d. The value of the dynamic variable d can be set appropriately according to the application. Because the texture data is such that color tone density gradients are formed in two mutually orthogonal directions, smooth shading is possible, and a plurality of texture memory areas can be consolidated to conserve memory usage.

BACKGROUND OF THE INVENTION

1. Field of the Invention

This invention relates to a data structure for texture data, and inparticular to a data structure appropriate for cell shading.

2. Description of the Related Art

In conventional computer graphics, a technique called cell shading isknown as a method of texture mapping using multiple textures. Cellshading is also called toon shading; in this shading method, thedistance between the object (the model) for texture mapping and thelight source, as well as the angles made by normal vectors to the objectsurface, are used to compute texture data UV coordinates (readaddresses) and brightnesses and colors are appropriately filtered andtextures mapped to the object surface. FIG. 8 is a figure explaining thetexture data used in conventional cell shading. The texture data 70shown in the figure is used for shading processing from white to blackwhen the brightness of the object surface exceeds a constant threshold,and in the normalized UV coordinate system (0.0≦U≦1.0 and 0.0≦V≦1.0),comprises data regions 71 in which “white” data (0.0≦U ≦0.5 and0.0≦V≦1.0) is allocated as well as data regions 72 in which “black” data(0.5≦U≦1.0 and 0.0≦V≦1.0) is allocated. UV coordinates referenced duringtexture mapping can be computed using the following two equations.U=a*I+b  (1)V=c*I+d  (2)

Here I is the brightness value, computed from the inner product of thenormalized normal vector to the object surface and the normalized lightray vector, and a, b, c, d are constants. Because the cell shadingmethod is well known, the details of a, b, c, d are here omitted. If thebrightness I can be computed, the UV coordinates for the texture datacan be computed from equations (1) and (2). The movement locus of UVcoordinates when the value of the brightness I is changed is similar tothe straight line 73. As is clear from the figure, as a result of lightsource calculations, when setting the UV values at each vertex of theobject, a small U value is specified and white texture mapping isperformed at each portion for which the angle made by the object surfacenormal vector and the light ray vector is small and on which a largeamount of light is incident; on the other hand, a large U value isspecified and black texture mapping is performed at each portion forwhich the angle made by the object surface normal vector and the lightray vector is large and on which not much light is incident. In otherwords, when the U value exceeds 0.5, pixels on the object surface areshaded from white to black. Thus by performing shading processing usingthe two values of white and black, the difference between exposed facesand unexposed faces on the object surface can be made apparent, andso-called animation-style shading can be performed.

However, in conventional cell shading methods, it is necessary toprepare texture data for shading according to the light source color,distance between light source, and object, light intensity of the lightsource and other exposure conditions, and consequently there are theproblems of additional labor for the designer, and waste of hardwareresources. Further, in the past object details were represented intexture mapping by applying a two-dimensional design or pattern to atwo-dimensional plane; but when texture mapping is employed for shadingas described above, because texture data for shades suffices in only asingle-dimension direction, the use of two-dimensional texture data astexture data for shading results in wasted memory. This problem isexplained referring to FIGS. 9 and 10.

FIG. 9 explains a case in which the texture data to be used is changedaccording to the color of the light source; as the light sourcesilluminating the object 50, a red light source 41, green light source42, and blue light source 43 are arranged in a virtual space. Threetypes of texture data are prepared for binary shading processingaccording to each light source color. In the state shown in the drawing,because the object 50 is in the position of the green light source 42,texture data for green shading processing is used to perform texturemapping. However, when the object 50 crosses the boundary 61 between thered light source 41 and green light source 42 to move to the side of thered light source 41, the texture data for the green light source 42 canno longer be used for shading, and shading must be performed using thetexture data for the red light source 41. When the texture data to beused is suddenly changed at the border line 61, the shading displayed onthe surface of the object 50 suddenly changes, and the appearance of thegraphic display is extremely unnatural. The case in which the object 50crosses the boundary 62 between the green light source 42 and blue lightsource 43 to move to the side of the blue light source 43 is similar.

FIG. 10 explains a case in which the texture data used is changedaccording to the positional relation between the camera (virtualviewpoint) and object; the light source 40, object 50, and camera 60 arearranged in prescribed positions. In three-dimensional computergraphics, each of the polygons comprised by the object 50 ismodeling-transformed into world coordinates, and after performingfield-of-view transformation to the camera viewpoint as seen from thecamera 60, three-dimensional clipping processing, hidden surfaceelimination, texture mapping, shading processing, display priorityprocessing, and other processing, the result is displayed on a videodisplay. Because the shading to which the object 50 is subjected isviewed differently according to the distance between the camera 60 andobject 50, texture data for a plurality of types of shading processingare prepared in advance, and when the distance between the object 50 andcamera 60 exceeds a certain distance, the texture used in shading ischanged. In the example of the drawing, when the object 50 crosses overthe boundary 63 and moves farther from the camera 60, the texture usedis changed. However, if the texture used changes suddenly at theboundary 63, the shades displayed on the surface of the object 50changes suddenly, and the appearance of the graphic display is extremelyunnatural.

However, of the texture data 70 shown in FIG. 8, the data actually usedis only the data on the straight line 73, and the other data regions arenot used, and the problem of considerable waste of memory for texturedata storage has been noted.

SUMMARY OF THE INVENTION

An object of the present invention is to propose a data structure fortexture data, a program to cause a computer system to execute texturemapping, and texture mapping method, and a texture mapping device whichresolve the above-described problems and enable smooth shading whilealso conserving memory resources.

In order to resolve the above problems, this invention provides a methodcomprising a step in which, in order to access texture data comprising acomputer-readable data region in which color data forming densitygradients in two mutually orthogonal directions is arranged, coordinatesare calculated in order to access the above data region in one of thedirections among the above two directions, using brightness informationof the object surface for texture mapping based on a prescribedequation; a step to calculate coordinates to access the above dataregion in the other direction of the above two directions based on anarbitrary value substituted into a dynamic variable; and, a step to readcolor data by accessing the above data region based on the calculatedcoordinates and perform texture mapping to the surface of the aboveobject.

Further, the present invention can provide computer-readable recordingmedia on which is recorded a computer program to cause a computer systemto execute the above method. Such recording media may be, for example,optical recording media (such as CD-RAM, CD-ROM, DVD-RAM, DVD-ROM,DVD-R, PD discs, MD discs, MO discs, and other recording media the dataof which can be read optically), magnetic recording media (such asflexible disks, magnetic cards, magnetic tape, and other recording mediathe data of which can be read magnetically), as well as memorycartridges comprising DRAM, SRAM, MRAM, FRAM, or other memory devices,and other transportable recording media.

Moreover, the above program can be distributed on demand from a Webserver or other network server in response to a request from a clientdevice (such as a personal computer, game equipment, portable telephoneequipped with a Web browser, PDA, Palm-type PC, or other portableinformation terminal or similar) connected to the Internet or to apacket communication or other open network.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a drawing which explains texture data;

FIG. 2 is a drawing which explains texture data;

FIG. 3 is a drawing which explains texture mapping;

FIG. 4 is a drawing which explains texture mapping;

FIG. 5 is a drawing which explains texture mapping;

FIG. 6 is a drawing which explains texture mapping;

FIG. 7 is a functional block diagram of the generation of video signals;

FIG. 8 is a drawing which explains conventional texture data;

FIG. 9 is a drawing which explains conventional texture mapping; and,

FIG. 10 is a drawing which explains conventional texture mapping.

DESCRIPTION OF THE PREFERRED EMBODIMENTS

Below, aspects of this invention are explained, referring to thedrawings.

FIG. 7 is a functional block diagram of texture mapping onto an objectusing texture data for shading, to output video signals to a videodisplay. In the figure, 11 is texture memory in which is stored texturedata, 12 is a filter, 13 is frame memory for writing one screen's worthof image data, and 14 is a video signal generation unit to output videosignals to a video display. After the results of light sourcecalculations corresponding to individual pixels on the object surface orthe vertices of polygons comprised by the object, which are brightnessdata and color data corresponding to each pixel or to the vertices ofpolygons, are read from texture memory 11, filter computations areperformed in the filter 12, referring to the brightness data and colordata of surrounding pixels, and the processing results are written toframe memory 13. The video signal generator unit 14 generates videosignals based on the image data written to the frame memory 13, andoutputs the signals to a video display, not shown.

FIG. 1 is a drawing which explains the texture data of this aspect. Thetexture data 20 shown in the drawing is, for convenience in explanation,shown with the texture in a state of expansion in a two-dimensionalplane; however, the state in which data is stored in the texture memory11 need not necessarily be expanded in a two-dimensional plane, and thedata structure of the texture data is identical so long as theinterrelation between color data at arbitrary coordinates of the texturedata shown in the drawing is satisfied. In other words, “data structure”in this specification does not signify the interrelation betweenindividual data bits in the state in which the texture data is stored inmemory or other recording media, but refers instead to the interrelationbetween color data at individual coordinates defined by texture dataread addresses. Color data comprises, in the case of chromatic colors,information relating to brightness, hue, and color saturation, and inthe case of achromatic colors, information relating to brightness(brightness and darkness). In the case of transparent colors, color datacomprises information relating to transparency; in the case of coloredtranslucence, color data comprises, in addition to transparency,information relating to brightness, hue, and saturation.

As shown in FIG. 3, the texture data 20 is prepared for use in shadingof the object surface in cases where the object 50 moves in the lateraldirection in the drawing under the red, green, and blue light sources41, 42 and 43. In the texture data 20, white texture data is allocatedin data region C10 in which 0.0≦U≦0.5 and 0.0≦V≦1.0, and texture datafor use in shading for the light sources 41, 42, 43 is allocated atsubstantially equal intervals in data regions C1 to C9, in which0.5≦U≦1.0 and 0.0≦V≦1.0. More specifically, C1 is deep red texture data,C2 is light red, C3 is a mixture of light red and light green, C4 islight green, C5 is dark green, C6 is light green, C7 is a mixture oflight green and light blue, C8 is light blue, and C9 is dark bluetexture data. That is, texture data for shading in a plurality ofdifferent color tones is arranged in the V coordinate direction,according to the positions of the light sources 41, 42 and 43. In theexample shown in the drawing, for convenience in explanation, a densitygradient is provided in nine stages; however, in actuality a finerdensity gradient, with several tens of stages, may be provided. Ofcourse, setting the U coordinate and V coordinate of the texture in theopposite manner does not change the essence of this invention. Byproviding a density gradient which is appropriate to the application,various shading processing can be performed, from animation-styleshading processing with binary shades, to comic-style shading processingwith multi-value shades. In this aspect, when using the texture data 20to perform shading, equation (1) is employed to compute the U valuethrough light source calculations, and in place of equation (2), thefollowing equation (3) is used to determine the V value.V=d  (3)

According to equation (3), the V value can be set by the value of thevariable d, regardless of the brightness I. The variable d is a dynamicvariable which can be changed arbitrarily by the program, and can, forexample, be changed in realtime according to the distance between thelight source and object; moreover, the variable d can be changed asappropriate according to an unfolding game situation in a virtual space(for example, according to whether a player is in a favorable situationor not, or whether the number of points scored is increased or not),regardless of the positional relation with the light source. The valueto which the variable d is set can be decided appropriately by theprogrammer according to various applications, such as whether thisinvention is to be used for computer graphics art or for gameapplications.

For example, in the example of FIG. 1, if the value of d is set to 0.15,light red shading enables representation of a weak contrast, whereas ifthe value of d is set to 0.9, dark blue shading can be used to representa strong contrast. If the value of d is defined in association with thedistance from the light source, the value of d can be changed inrealtime in concert with the positional relation between the lightsource and the object. For example, in the example of FIG. 3 acoordinate axis is set in the lateral direction in the drawing, and ifthe position of the light source 41 is set to d=0.0, the position of thelight source 42 is set to d=0.5, and the position of the light source 43is set to d=1.0, then as the object 50 approaches the light source 41,the value of d approaches to 0.0; as the object 50 approaches the lightsource 42, the value of d approaches 0.5; and as the object 50approaches the light source 43, the value of d approaches 1.0. In theexample of the drawing, the object 50 is slightly to the left of theposition of the light source 42; if the value of d on the abovecoordinate axis is determined to be d=0.35, the color of shades on thesurface of the object 50 will be light green.

In this way, by using the U value for shading, and using the V value forcolor tone control of the shades, smooth shading processing for lightsources with three colors can be realized. And because there is nosudden change in the color tone of shades at a boundary set in advanceby the positional relation with light sources, as in the prior art,smooth shading without abnormalities can be realized. Also, in the priorart it was necessary to prepare a plurality of texture data setsaccording to the number of light sources, but in the present aspect onlyone data set is necessary, so that the labor of a designer creating aplurality of texture data sets can be eliminated, and texture memoryrequirements can be reduced.

Another usage example employing the texture data of this aspect isexplained below. If it is supposed that a density gradient is set suchthat the texture data gradually changes from dark black to light blackas the value of d increases from 0.0 to 1.0, then the shade contrast canbe changed in concert with the positional relation between light sourceand object. For example, in FIG. 4, a coordinate axis is set in thelateral direction in the drawing, and if the position of the lightsource 40 is d=0.0, then as the object moves away from the light source40, the value of d changes from d=0.0 to d=1.0. For example, at d=0.3the distance between the light source 40 and the object 50 is relativelysmall, so that shading is performed using shades with a comparativelystrong contrast, whereas when d=0.8 the distance between the lightsource 40 and object 50 is relatively large, so that shading isperformed using shades with a comparatively weak contrast. In otherwords, in moving away from the light source 40, the intensity of lightincident on the object surface weakens in inverse proportion to thesquare of the distance, so that shading with gradually weaker contrastis performed, and an effect equivalent to the effect of lighting can beobtained.

FIG. 5 is a drawing explaining the case in which the value of d ischanged in concert with the distance between the camera 60 and object 50to perform shading. A coordinate axis is set in the lateral direction inthe drawing, and if the position of the camera 60 is d=0.0, then thevalue of d changes from d=0.0 to d=1.0 as the object moves away from thecamera 60. If it is supposed that a density gradient is set such that,as the value of d increases from 0.0 to 1.0, the texture data changesgradually from dark black to light black, then as the object moves awayfrom the camera 60, shading is performed with gradually weaker contrast,and an effect similar to fog can be obtained.

This invention is not limited to cases in which the value of d ischanged according to the distance between the light source or camera andthe object to perform shading; for example, the light intensity of thelight source may be associated with the value of d to perform shading.For example, if the value of d is 0.0 for a light source for which thelight intensity is maximum, and the value of d is gradually increased asthe light intensity gradually weakens, so that the value of d is 1.0 fora light source with minimum light intensity, then fine adjustment of theshade contrast can be performed according to the magnitude of the lightintensity of the light source. However, in this case it is assumed thata density gradient is set such that, as the value of d increases from0.0 to 1.0, the texture data changes gradually from dark black to lightblack. Further, as an example of setting of the d value, the value of dmay be associated with the distance from the object to sea level, orwith the distance between objects, or with other game parameters.

FIG. 2 shows another example of texture data. The texture data 30 shownin the drawing is arranged in a white data region C11, light gray dataregion C12, gray data region C13, dark gray data region C14, and blackdata region C15, so as to form curved density gradients in the Ucoordinate direction and in the V coordinate direction. Equation (1) isused to determine the U value of texture data 30 through light sourcecalculations, and equation (3) is used to determine the V value. Byusing the texture data 30, the number of gray scales of the shadescorresponding to the d value can be adjusted. For example, if the dvalue is 0.2, the V value can take the values of any of the data regionsC11, C13, or C15, so that three values are possible for shades; if the dvalue is 0.8, the V value can take the values of any of the data regionsfrom C11 to C15, so that five values are possible for shades. FIG. 6explains an example of application of shading using the texture data 30;by increasing or decreasing the value of d in concert with the number ofpoints obtained by a player in a game, the number of gray scales ofshades is adjusted. In the example of the drawing, when there are nopoints, the number of gray scales is set to 3 by setting the d value to0.2, and when there are numerous points, the number of gray scales isset to 5 by setting the d value to 0.8. Because the number of grayscales of the shades of a game character or other object can be adjustedfreely in concert with the number of points acquired by a player, theatmosphere of a character can be freely changed from animation-style tocomic-style as the game unfolds, so that the game can be made moreamusing.

As explained above, by means of this aspect, the color tone of thetexture is changed not only in the U coordinate direction, but in the Vcoordinate direction as well; hence it is possible, for example, toapply shading in a smooth transition from red shades to blue shades, andthe color tone of the shades can be changed naturally and withoutabnormalities. And because the texture for shading has a design inadvance, more complex drawing can easily be performed compared with thecontinuous changes of conventional fog. Also, whereas in the prior art aplurality of texture data sets were prepared corresponding to the numberof light sources or other conditions, in this aspect the plurality oftexture data sets can be consolidated into a single texture data set, sothat the hit rate of the cache can be raised, and the drawing speed canbe increased. Also, the V value can be specified independently andregardless of the brightness I, so that data regions in the entirety ofthe texture data can be utilized effectively, with no waste of texturememory.

According to this aspect, in addition to the number of color tons andnumber of stages of shades, highlights which appear in stages, increasesand decreases in reflected light amounts, changes in the exposed area ofthe object surface, changes in color tones and color saturation, changesin transparency, and other parameters can be freely adjusted. And, byappropriately changing the setting of the d value, noise-likerepresentations, as well as changes in light amounts which give a“dancing” effect as if light from a flame were incident, and changes inthe area ratios of shaded portions and exposed portions, can berepresented. Also, by changing the value of d at each vertex of theobject, complicated point light sources can be represented, changes inthe shades only of specific portions of the object surface can berepresented, and a luster only at a specific portion can be represented.In addition to texture mapping to an object comprising polygons, thisinvention can also be used in texture mapping to NURBS and other curvedsurfaces.

By means of this invention, texture mapping is performed using texturedata comprising computer-readable data regions in which color data isarranged forming density gradients in two mutually orthogonaldirections, so that coordinates to access the texture data can becomputed from a value computed from object surface brightnessinformation using a prescribed equation and from a value computed basedon an arbitrary value assigned to a dynamic variable, and the colortone, density, and other parameters of the texture data to be read canbe changed appropriately according to the assigned value of the dynamicvariable. Hence shading with different shade colors can be displayedwith natural transitions. Also, a plurality of texture data sets can beconsolidated into a single texture data set, so that texture memoryrequirements can be reduced.

1-11. (canceled)
 12. A texture mapping method, which maps a texture toan object, comprising: calculating first coordinate information in orderto access a data region of said texture data in one direction of twomutually orthogonal directions defined for the texture data, frominformation set for said object surface; calculating second coordinateinformation in order to access a data region of said texture data in theother direction of said two mutually orthogonal directions, frominformation other than information set for said object surface; readingcolor data from said texture data by accessing said data region based onsaid first and second coordinate information; and performing texturemapping to said object surface. 13-21. (canceled)
 22. A texture mappingdevice for mapping a texture to an object, comprising: means forcalculating first coordinate information in order to access a dataregion of texture data in one direction of two mutually orthogonaldirections defined for said texture data from information set on thesurface of said object; means for calculating second coordinateinformation in order to access a data region of said texture data in theother direction of said two directions from information other thaninformation set on the surface of said object; and means for accessingsaid data region based on said first and second coordinate informationto read color data from said texture data and to perform texture mappingto said object surface.